package com.zx.shiro.service;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.Logical;
import org.apache.shiro.authz.annotation.RequiresRoles;
import org.apache.shiro.session.Session;
import org.springframework.stereotype.Service;

@Service
public class ShiroService {

	public void testMethod(){
		System.out.println("testMethod, time: "+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
		
		//使用Shiro的Session也可以获取到HttpSession中的值，不用从Controller中传递过来了。
		Session session = SecurityUtils.getSubject().getSession();
		System.out.println("Service sessionValue = "+session.getAttribute("key"));
	}
}
